package src.unapec.security.models.EntornoJava;/**
 * By default, this applet raises a security exception, unless
 *  you configure your policy to allow applets from its location
 *  to write to the file "writetest".
 */

import java.applet.Applet;
import java.awt.Graphics;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class SeguridadApplet extends Applet {

	String myFile = "/home/rmatos/Desktop/Seguridad/writetest.txt";
	File f = new File(myFile);
	DataOutputStream dos;

	public void init() {

		String osname = System.getProperty("os.name");
	}

	public void paint(Graphics g) {
		try {
			dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
			dos.writeChars("This is only a Test \n");
			dos.flush();
			g.drawString("Escritura de Archivo Satisfactoria " + myFile + " Abrelo", 10, 10);
		}
		catch (SecurityException e) {
			g.drawString("writeFile: Excepcion de Seguridad: " + e, 10, 10);
		}
		catch (IOException ioe) {
			g.drawString("writeFile: Excepcion de Escritura", 10, 10);
		}
	}
}

